<%attr>
	sHead => "edit article"
</%attr>

<%args>
	$title => undef
	$subcat_id => undef
	$doctext => undef
</%args>
<%init>
	my @subcategories = $m->comp('../dao/subcategory_dao.mi:findAll');
	 
	my $article = $m->comp("../dao/article_dao.mi:findById", id => $m->notes('url_id'));
	my $field_constraints = { 'subcat_id' => \@subcategories };
	my $field_names = ['title', 'subcat_id'];
	
	if (defined $doctext) {
		$article->{'doctext'} = $doctext;
		$article->{'title'} = $title;
		$article->{'subcat_id'} = $subcat_id;
		$article->{'previewtext'} = $doctext;
	}
	
	$m->comp("../view/article_full_edit.mi", entity => $article, entity_name => 'article', 
		field_names => $field_names,
		field_titles => { 'title' => 'title', 'subcat_id' => 'sub-category'},
		field_constraints => $field_constraints
		);
</%init>
